# 定义蓝图
from flask import Blueprint
from flask_restplus import Api
from app.settings import constants

# from common.utils.output_json import output_json
from .user.views import (
    UserLoginView,
    UserTokenView,
    UserInfoView,
    UserListView,
    UserRoleListView,
    UserPutDeleteView,
)
from .user.views import user_ns
from .car.views import car_ns, CarListCreateView, CarPutDeleteView
from .data_collection.views import (
    data_collection_ns,
    DataCollectionListView,
    DataCollectionChangeView,
    CollectionImageView,
    CollectionImageDeleteView,
)

from .park_collection.views import (
    parking_collection_ns,
    ParkingCollectionImageView,
    ParkingCollectionImageDeleteView,
    ParyingCollectionChangeView,
    ParyingCollectionListView,
)

from .cost.views import (
    cost_ns,
    RoadCostListCreateView,
    RoadCostPutDeleteView,
    RuelCostListCreateView,
    RuelCostPutDeleteView,
    ParkingCostPutDeleteView,
    ParkingCostListCreateView,
    RuelImageView,
    RuelImageDeleteView,
    ParkingImageDeleteView,
    PakingImageView,
    RoadImageView,
    RoadImageDeleteView,
)

from .home_data.views import (
    home_data_ns,
    AssetDetailsView,
    AssetCarNumView,
    CarDetailsView,
    CollentionDetailsView,
    ImportFileView,
    CarDataCostView,
)

# 生成蓝图对象
bp = Blueprint("hello_word", __name__, url_prefix=constants.BASE_URL_PREFIX)
# 生成Api对象
api = Api(bp, title="理想汽车车辆管理", description="lixiang-system", doc="/docs")

# 添加名字空间
api.add_namespace(user_ns)
api.add_namespace(data_collection_ns)
api.add_namespace(car_ns)
api.add_namespace(cost_ns)
api.add_namespace(home_data_ns)
api.add_namespace(parking_collection_ns)

# 注册路由
home_data_ns.add_resource(AssetDetailsView, "/asset-user-details")
home_data_ns.add_resource(AssetCarNumView, "/asset-car-details")
home_data_ns.add_resource(CarDetailsView, "/car-user/<id>")
home_data_ns.add_resource(CollentionDetailsView, "/colletion-user/<id>")
home_data_ns.add_resource(ImportFileView, "/import-file")
home_data_ns.add_resource(CarDataCostView, "/car-data-cost")

user_ns.add_resource(UserLoginView, "/register")
user_ns.add_resource(UserTokenView, "/token")
user_ns.add_resource(UserInfoView, "/info")
user_ns.add_resource(UserListView, "/user-list")
user_ns.add_resource(UserRoleListView, "/role-list")
user_ns.add_resource(UserPutDeleteView, "/info/<id>")

data_collection_ns.add_resource(DataCollectionListView, "/collection-info")
data_collection_ns.add_resource(DataCollectionChangeView, "/collection-info/<id>")
data_collection_ns.add_resource(CollectionImageView, "/collection-images")
data_collection_ns.add_resource(CollectionImageDeleteView, "/collection-images/<id>")


parking_collection_ns.add_resource(ParyingCollectionListView, "/parking-collection-info")
parking_collection_ns.add_resource(ParyingCollectionChangeView, "/parking-collection-info/<id>")
parking_collection_ns.add_resource(ParkingCollectionImageView, "/parking-collection-images")
parking_collection_ns.add_resource(
    ParkingCollectionImageDeleteView, "/parking-collection-images/<id>"
)


car_ns.add_resource(CarListCreateView, "/car-info")
car_ns.add_resource(CarPutDeleteView, "/car-info/<id>")

cost_ns.add_resource(RuelCostListCreateView, "/ruel-cost")
cost_ns.add_resource(RuelCostPutDeleteView, "/ruel-cost/<id>")

cost_ns.add_resource(RuelImageView, "/ruel-images")
cost_ns.add_resource(RuelImageDeleteView, "/ruel-images/<id>")

cost_ns.add_resource(RoadImageView, "/road-images")
cost_ns.add_resource(RoadImageDeleteView, "/road-images/<id>")

cost_ns.add_resource(PakingImageView, "/parking-images")
cost_ns.add_resource(ParkingImageDeleteView, "/parking-images/<id>")

cost_ns.add_resource(RoadCostListCreateView, "/road-cost")
cost_ns.add_resource(RoadCostPutDeleteView, "/road-cost/<id>")
cost_ns.add_resource(ParkingCostListCreateView, "/parking-cost")
cost_ns.add_resource(ParkingCostPutDeleteView, "/parking-cost/<id>")
# 设置返回json格式
# hello_api.representation("application/json")(output_json)
# 注册蓝图
